const fs = require('fs');
const path = require('path');
const util = require('util');

const fs_stat = util.promisify(fs.stat);
const fs_access = util.promisify(fs.access);

async function is_file_existed() {
  await fs_access(path.resolve(__dirname, './test.js'));
  await fs_access(path.resolve(__dirname, './yes.js'));
}

is_file_existed()
  .then((status) => {
    console.log('Status: \r\n', status);
  })
  .catch((err) => {
    console.log('Error: \r\n', err);
    return 'yse';
  })
  .then((status) => {
    console.log('Status2: \r\n', status)
  })
  .catch((err) => {
    console.log('Error: \r\n', err);
  });


async function multi_return() {
  await 1;
  throw new Error('err11111');
  await 3;
  throw new Error('err11111');
  throw new Error('err11111');
  return 5;
}

multi_return()
  .then(result => {
    console.log('then1>', result);
  })
  .catch(err => {
    console.log('err1>\r\n', err);
  })
  .then(result => {
    console.log('then2>\r\n', result);
  })
  .catch(err => {
    console.log('err2\r\n', err);
  })
  .then(result => {
    console.log('then3\r\n', result);
  })
  .catch(err => {
    console.log('err3>\r\n', err);
  });